package com.navinfo.platform.bigdata.dto;

import com.navinfo.platform.bigdata.util.EntityConvert;
import com.navinfo.stream.qingqi.protocol.java.LCPredictiveMaintenance;

public class MaintenanceEvent5Dto {
    private int alarmInformation;
    private double transmissionOilTemperature;

    public int getAlarmInformation() {
        return alarmInformation;
    }

    public void setAlarmInformation(int alarmInformation) {
        this.alarmInformation = alarmInformation;
    }

    public double getTransmissionOilTemperature() {
        return transmissionOilTemperature;
    }

    public void setTransmissionOilTemperature(double transmissionOilTemperature) {
        this.transmissionOilTemperature = transmissionOilTemperature;
    }

    public static MaintenanceEvent5Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent5 maintenanceEvent5){
        MaintenanceEvent5Dto maintenanceEvent5Dto = new MaintenanceEvent5Dto();
        maintenanceEvent5Dto.setAlarmInformation(maintenanceEvent5.getAlarmInformation());
        maintenanceEvent5Dto.setTransmissionOilTemperature(maintenanceEvent5.getTransmissionOilTemperature());
        return maintenanceEvent5Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent5
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent5 maintenanceEvent5){
        return EntityConvert.convert(
                maintenanceEvent5.getAlarmInformation(),
                maintenanceEvent5.getTransmissionOilTemperature()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent5 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent5.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=5){
                builder = LCPredictiveMaintenance.MaintenanceEvent5.newBuilder();
                builder.setAlarmInformation(Integer.valueOf(revert[0]));
                builder.setTransmissionOilTemperature(Double.valueOf(revert[1]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }
}
